Fix minimum maximum validators with type array#1227
Merged
stevehu merged 1 commit intonetworknt:masterfrom Jan 21, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes an issue where minimum, maximum, exclusiveMinimum, and exclusiveMaximum validators did not work correctly when the schema's type field was an array (e.g., ["null", "integer"]). The fix refactors the type checking logic from using getNodeFieldType() to a new hasType(String type) method that can handle both string and array type values.
Changes:
- Refactored
getNodeFieldType()method tohasType(String type)inBaseKeywordValidatorto support array type checking - Updated four validator classes to use the new
hasType()method instead ofgetNodeFieldType() - Added comprehensive test coverage for all four validators with array type scenarios
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java | Replaced getNodeFieldType() with hasType() method to support array type checking |
| src/main/java/com/networknt/schema/keyword/MinimumValidator.java | Updated to use hasType() instead of getNodeFieldType() |
| src/main/java/com/networknt/schema/keyword/MaximumValidator.java | Updated to use hasType() instead of getNodeFieldType() |
| src/main/java/com/networknt/schema/keyword/ExclusiveMinimumValidator.java | Updated to use hasType() instead of getNodeFieldType() |
| src/main/java/com/networknt/schema/keyword/ExclusiveMaximumValidator.java | Updated to use hasType() instead of getNodeFieldType() |
| src/test/java/com/networknt/schema/MinimumValidatorTest.java | Added test for minimum validator with array type |
| src/test/java/com/networknt/schema/MaximumValidatorTest.java | Added test for maximum validator with array type |
| src/test/java/com/networknt/schema/ExclusiveMinimumValidatorTest.java | Added test for exclusiveMinimum validator with array type |
| src/test/java/com/networknt/schema/ExclusiveMaximumValidatorTest.java | New test file for exclusiveMaximum validator with array type |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/main/java/com/networknt/schema/keyword/BaseKeywordValidator.java
Outdated
Show resolved
Hide resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1226